package com.uh.microservice.core.spring;

import com.github.yitter.contract.IdGeneratorOptions;
import com.github.yitter.idgen.YitIdHelper;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * 容器初始化类
 * Created by liming on 2017/9/15.
 */
public class UxInitializingBean implements ApplicationContextInitializer<ConfigurableApplicationContext>,ApplicationListener {

    protected ConfigurableApplicationContext app;
    private static boolean inited=false;

    /**
     * 在初始化类中设置Application的属性，和上下文等信息
     */
    public  void initialize(ConfigurableApplicationContext context){
        app=context;
        SpringUtil.setAPP(app);
        IdGeneratorOptions options = new IdGeneratorOptions((short)1);
        YitIdHelper.setIdGenerator(options);
    }

    /**
     * 事件监听
     */
    public void onApplicationEvent(ApplicationEvent applicationEvent){

    }
}
